<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <form>
        <div>
            <label for="fname">First name:</label>
            <input type="text" id="fname">
        </div>

        <div>
            <label for="lname">First name:</label>
            <input type="text" id="lname">
        </div>
        <div>
            <input type="submit" id="submit">
        </div>
        <p></p>
    </form>

    <script>
    let fname = document.getElementById('fname')
    let form = document.querySelector('form')
    let lname = document.getElementById('lname')
    let submit = document.getElementById("submit")
    let p = document.querySelector('p')

    form.onsubmit = function(evt) {
        if(fname.value==='' || lname.value==='') {
            evt.preventDefault();
            p.textContent="您提交的数据有误!!!"
        }
    }
    </script>
</body>

</html>